package com.xyh.transaction.controller;

import com.github.pagehelper.PageInfo;
import com.xyh.transaction.entity.dto.log.LogSearchDto;
import com.xyh.transaction.entity.vo.LogLevelVo;
import com.xyh.transaction.entity.vo.LogMethodVo;
import com.xyh.transaction.entity.vo.LogVo;
import com.xyh.transaction.response.ResponseResult;
import com.xyh.transaction.service.LogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Set;

@Slf4j
@Api(tags = "日志管理")
@RestController
@RequestMapping("log")
public class LogController {

    @Autowired
    private LogService logService;


    @ApiOperation(value = "日志列表",notes = "返回日志分页数据")
    @PostMapping("list")
    public ResponseResult<PageInfo<LogVo>> list(@RequestBody LogSearchDto logSearchDto){
        PageInfo<LogVo> pageInfo = logService.getList(logSearchDto);
        log.info("查询成功！");
        return ResponseResult.success("查询成功！",pageInfo);
    }

    @ApiOperation(value = "日志等级列表",notes = "返回所有日志等级")
    @GetMapping("level")
    public ResponseResult<Set<LogLevelVo>> levelList(){
        Set<LogLevelVo> data = logService.getLevelList();
        return ResponseResult.success("查询成功！",data);
    }

    @ApiOperation(value = "请求方法列表",notes = "返回所有请求方法")
    @GetMapping("method")
    public ResponseResult<Set<LogMethodVo>> methodList(){
        Set<LogMethodVo> data = logService.getMethodList();
        return ResponseResult.success("查询成功！",data);
    }

}
